/**
 *	模块的
 *	开发者：雨中磐石
 *	地址：www.rockoa.com
 *	日期：2023-07-25
 */

package com.framework.Model;

import com.framerock.db.DB;
import com.framerock.db.DBConn;
import com.framerock.baselib.Rock;

import java.util.ArrayList;
import java.util.Map;
import com.framework.ACore.Model;


/**
 * 用户模型
 * */
public class ModelUsera extends Model {

    private ModelDept modelDept = null;

    public ModelUsera(DBConn dbs) {
        super(dbs);
        this.setTable("usera");
    }

    public static ModelUsera get(DBConn dbs)
    {
        return new ModelUsera(dbs);
    }

    /**
     * 获取部门的
     * */
    public ModelDept dept()
    {
        if(modelDept == null)modelDept = ModelDept.get(this.nDb);
       return modelDept;
    }

    /**
     * 获取单位人员信息关联头像
     * */
    public Map<String,String> getUsera(String aid)
    {
        String key = "a"+aid+"";
        Map<String,String> rs = this.XinxiInfo.get(key);
        if(rs != null)return rs;

        String sql = "SELECT b.`face`,a.`id`,a.`name`,a.`deptname` FROM `"+DB.chuliPerfix("usera")+"` a LEFT JOIN `"+DB.chuliPerfix("users")+"` b ON a.`uid` = b.`id` WHERE a.`id`="+aid+"";
        rs  = this.nDb.getOne(sql);
        this.XinxiInfo.put(key, rs);
        return rs;
    }

    /*
    * 人员头像
    **/
    public String getFace(String aid)
    {
        return Rock.getMapString(getUsera(aid), "face");
    }
}
